<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var date1 = new Date();

    var year = date1.getFullYear();
    console.log(year);//获取当前年份

    var Month = date1.getMonth();//获取的月份0-11，比实际月份小1
    Month = Month + 1;//获取当前月份
    console.log(Month);

    //获取星期 日期对象.getDay();
    //获取星期的取值是0-6，每个星期第一天是星期日
    var weeks = ["星期一","星期二","星期三","星期四","星期五","星期六","星期日"];
    var weekday = date1.getDay();
    console.log(weekday);

    //getDate 获取今天的日期
    var day = date1.getDate();

    var hour = date1.getHours();
    var min = date1.getMinutes();
    var sec = date1.getSeconds();
    console.log(hour,min,sec);
</script>
</html>